<template>
  <div class="show_schedule">
    <span class="pull-right">
      <button class="btn btn-danger delete" v-on:click="deleteschedule(schedule.id)">删除</button>
      <router-link to="/Schedule/Center" class="btn btn-warning">返回</router-link>
    </span>
    <div class="single_schedule">
      <p class="schedule_type">日程紧急度：{{schedule.degree}}</p>
      <p>{{schedule.body}}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Singleschedule',
  data () {
    return {
      schedule: {}
    }
  },
  methods: {
    fetchschedules (scheduleid) {
      this.$http.get('http://localhost:3000/schedule/' + scheduleid)
        .then(function (data) {
          console.log(data)
          this.schedule = data.body
        })
    },
    deleteschedule (id) {
      // console.log(id);
      this.$http.delete('http://localhost:3000/schedule/' + id)
        .then((response) => {
          this.$router.push({path: '/Schedule/Center', query: {alert: '日记删除成功!'}})
        })
    }
  },
  created () {
    this.fetchschedules(this.$route.params.id)
  }
}
</script>

<style scoped>
  .single_schedule{
    max-width: 960px;
    padding: 100px 50px;
    margin: 30% auto;
    border: 1px dotted #aaa;
  }
  h1{
    text-transform: uppercase;
    text-align: center;
    padding: 10px 0;
    font-weight: bolder;
    color: #66cdaa;
  }
  .schedule_type{
    color: red;
    font-size: 15px;
    text-align: right;
    padding-bottom: 5px;
  }
</style>
